package cn.sdstudio.controller;

import cn.sdstudio.model.Result;
import cn.sdstudio.service.FileUploadService;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author Zyq
 * @version 1.0
 * @date 2025/5/2 周五
 */
@RequestMapping("/upload")
@RequiredArgsConstructor
@RestController
@Slf4j
@Schema(description = "图片上传功能")
public class FileUploadController {

    private final FileUploadService fileUploadService;

    /**
     * 图片上传功能
     * @param file
     * @return
     */
    @PostMapping()
    @Schema(description = "图片上传")
    public Result uploadAvatar(@RequestParam("file") MultipartFile file){
        return Result.success(fileUploadService.uploadAvatar(file));
    }


}
